﻿var viewStatus = this.lookupController().analysis().status,
    vm = this.lookupViewModel();

if (viewStatus == 'launch' || viewStatus == 'resubmit') {
    var serviceStart = ref.serviceStart.getValue();
    var serviceEnd = ref.serviceEnd.getValue();

    var serviceType = ref.serviceType.getValue();
    if (serviceType != 5 && serviceType != 6) {
        ref.serviceEnd.setMinValue(newValue);
    } else {
        var maxDate = null;

        switch (serviceType) {
            case '5':
                //serviceDate时间控制
                if (serviceStart) {
                    maxDate = Ext.Date.add(serviceStart, Ext.Date.MONTH, 6);
                }
                break;
            case '6':
                //serviceDate时间控制
                if (serviceStart) {
                    var maxDate = Ext.Date.add(serviceStart, Ext.Date.MONTH, 2);
                }
                break;
        }
        vm.set('NebulogyForm.agencyInfo.serviceEnd', maxDate);
        ref.serviceEnd.setMaxValue(maxDate);
    }

    if (self.containsFocus && Ext.Date.diff(serviceStart, serviceEnd, Ext.Date.DAY) < 0) {
        vm.set('NebulogyForm.agencyInfo.serviceEnd', null);
    }
}